package com.czk.type;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.util.Printer;

/**
 * 指令的转换
 *
 * @Author:ChenZhangKun
 * @Date: 2021/8/12 14:54
 */
public class OrderTransform {
    public static void main(String[] args) {
        Type longType = Type.LONG_TYPE;
        // 拿到老指令
        int[] opcodes = new int[]{
                Opcodes.ILOAD,
                Opcodes.IASTORE,
                Opcodes.IALOAD,
                Opcodes.ISTORE,
                Opcodes.IADD,
                Opcodes.ISUB,
                Opcodes.IRETURN
        };
        for (int oldOpcode : opcodes) {
            int newOpcode = longType.getOpcode(oldOpcode);
            String oldName = Printer.OPCODES[oldOpcode];
            String newName = Printer.OPCODES[newOpcode];
            // ILOAD   --- LLOAD
            // IASTORE --- LASTORE
            // IALOAD  --- LALOAD
            // ISTORE  --- LSTORE
            // IADD    --- LADD
            // ISUB    --- LSUB
            // IRETURN --- LRETURN
            // 将类型进行转换
            System.out.printf("%-7s --- %-7s%n", oldName, newName);
        }
    }
}
